package com.neusoft.resturant.controller;

import com.neusoft.resturant.common.utils.PageResult;
import com.neusoft.resturant.common.utils.R;
import com.neusoft.resturant.entity.ResDishes;
import com.neusoft.resturant.service.IResDishesService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

/**
 * 菜品Controller
 * 
 * @author 文豪
 * @date 2023-10-11
 */
@RestController
@RequestMapping("/restaurant/dishes")
public class ResDishesController
{
    @Autowired
    private IResDishesService resDishesService;


    /**
     * 分页查询菜品
     */
    @GetMapping("/list2")
    public R list2(ResDishes resThumbup, Integer pageNum, Integer pageSize)
    {
        Integer pagesize=2;
        Integer pagenum=1;
        if(pageSize==null)
            pageSize=pagesize;
        if(pagenum==null)
            pageNum=pagenum;
        PageResult list = resDishesService.selectResThumbupList2(resThumbup,pageNum,pageSize);
        return R.success(list);
    }





    /**
     * 查询菜品
     */

    //    http://localhost:8080/restaurant/dishes/1
    @GetMapping("/{id}")
    public ResDishes getInfo(@PathVariable(value = "id") Long dishId) {
        System.out.println("id=" + dishId);
        ResDishes dishes = resDishesService.selectResDishesById(dishId);
        return dishes;
    }
/*
    /**
     * 新增菜品
     */


    @PostMapping("/add")
    public int add(@RequestBody ResDishes resDishes)
    {


        System.out.println("新增成功");
        return (resDishesService.insertResDishes(resDishes));
    }

    /**
     * 修改菜品
     */


    @PutMapping("/edit")
    public int edit(@RequestBody ResDishes resDishes)
    {
        System.out.println("修改成功");
        return (resDishesService.updateResDishes(resDishes));
    }

    /**
     * 删除菜品
     */

	@DeleteMapping("/remove/{id}")
    public int remove(@PathVariable Long[] id)
    {
        return (resDishesService.deleteResDishesByIds(id));
    }




}
